$(function (){

    alert("133");
var error_email = false;
var error_phone = false;
var error_password = false;
var error_check_password = false;
var error_check = false;


$('#email').blur(function (){
    check_email();
});

$('#phone').blur(function (){
    check_phone();
});

$('password').blur(function (){
    check_pwd();
})

$('passwordRepeat').blur(function (){
    check_cpwd();
})

$('reader-me').click(function (){
    if($(this).is(':checked'))
    {
        error_check = false;
    }
    else
    {
        error_check = true;
        $(this).next().text('请勾选同意');
    }
})



function check_email(){
    var geshi = /^[a-z0-9][\w\.\-]*@[a-z0-9\-]+(\.[a-z]{2,5}){1,2}$/;
    if (geshi.test($('#email').val())){
        $('#email').next().test("ok").css("color","green");
        error_email = false;
    }else {
        $('#email').next().test("邮箱格式错误").css("color","red");
        error_email = true;
    }
}

function check_phone(){
    var iphone = /^(13[0-9]|15[0-9]|18[0-9]|19[0-9])\d{8}$/;
    if (iphone.test($('phone').val())){
        $('phone').next().text("ok").css("color","green");
        error_phone = false;
    }else {
        $('phone').next().text("请输入正确的手机号").css("color","red");
        error_phone = true;
    }
}

function check_pwd(){
    var length = $('password').val().length;
    if (length<6 || length>20){
        $('password').next().text("密码最少8位，最长20位").css("color","red");
        error_password = true;
    }else {
        $('password').next().text("ok").css("color","green");
        error_password = false;
    }
}

function check_cpwd(){
    var pwd = $('password').val();
    var cpwd = $('passwordRepeat').val();
    if (pwd != cpwd){
        $('passwordRepeat').next().text("两次密码不一样").css("color","red");
        error_check_password = true;
    }else {
        $('passwordRepeat').next().text("ok").css("color","green");
        error_check_password = true;
    }
}

function check_agree(){
    $('.am-tabs-bd').submit(function (){
        if (error_email == false || error_phone == false && error_password == false && error_check_password == false && error_check == false){
            return true;
        }else {
            return false;
        }

    });

}
    console.log(333)





})

